Convert over to using an GtkInvisible - selections don't work properly
authorOwen Taylor <otaylor@redhat.com>
Mon, 25 Feb 2002 05:12:14 +0000 (05:12 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Mon, 25 Feb 2002 05:12:14 +0000 (05:12 +0000)
Sun Feb 24 23:23:28 2002  Owen Taylor  <otaylor@redhat.com>

* tests/testselection.c (main): Convert over to using
an GtkInvisible - selections don't work properly
with now NO_WINDOW GtkToggleButton. (Example really
should be using GtkClipboard.)

* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Fix  problems if sizeof(GdkAtom) != sizeof(Atom). (Unlikely)

* gdk/x11/gdkproperty-x11.c (gdk_property_get): Set
actual_length when converting atoms as well.
(Gregory Merchan, #72074)

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c
tests/testselection.c

index 0b7f35b4af68394138ef1939e4144ef06dfbcd5a..8ad5e26dae52fef94d1c3efdb002867a8157c6a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Sun Feb 24 23:23:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * tests/testselection.c (main): Convert over to using
+       an GtkInvisible - selections don't work properly
+       with now NO_WINDOW GtkToggleButton. (Example really
+       should be using GtkClipboard.)
+
+       * gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
+       Fix  problems if sizeof(GdkAtom) != sizeof(Atom). (Unlikely)
+
+       * gdk/x11/gdkproperty-x11.c (gdk_property_get): Set 
+       actual_length when converting atoms as well.
+       (Gregory Merchan, #72074)
+
 2002-02-24  Havoc Pennington  <hp@pobox.com>
        
        * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to
index 0b7f35b4af68394138ef1939e4144ef06dfbcd5a..8ad5e26dae52fef94d1c3efdb002867a8157c6a2 100644 (file)
@@ -1,3 +1,17 @@
+Sun Feb 24 23:23:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * tests/testselection.c (main): Convert over to using
+       an GtkInvisible - selections don't work properly
+       with now NO_WINDOW GtkToggleButton. (Example really
+       should be using GtkClipboard.)
+
+       * gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
+       Fix  problems if sizeof(GdkAtom) != sizeof(Atom). (Unlikely)
+
+       * gdk/x11/gdkproperty-x11.c (gdk_property_get): Set 
+       actual_length when converting atoms as well.
+       (Gregory Merchan, #72074)
+
 2002-02-24  Havoc Pennington  <hp@pobox.com>
        
        * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to
index 0b7f35b4af68394138ef1939e4144ef06dfbcd5a..8ad5e26dae52fef94d1c3efdb002867a8157c6a2 100644 (file)
@@ -1,3 +1,17 @@
+Sun Feb 24 23:23:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * tests/testselection.c (main): Convert over to using
+       an GtkInvisible - selections don't work properly
+       with now NO_WINDOW GtkToggleButton. (Example really
+       should be using GtkClipboard.)
+
+       * gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
+       Fix  problems if sizeof(GdkAtom) != sizeof(Atom). (Unlikely)
+
+       * gdk/x11/gdkproperty-x11.c (gdk_property_get): Set 
+       actual_length when converting atoms as well.
+       (Gregory Merchan, #72074)
+
 2002-02-24  Havoc Pennington  <hp@pobox.com>
        
        * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to
index 0b7f35b4af68394138ef1939e4144ef06dfbcd5a..8ad5e26dae52fef94d1c3efdb002867a8157c6a2 100644 (file)
@@ -1,3 +1,17 @@
+Sun Feb 24 23:23:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * tests/testselection.c (main): Convert over to using
+       an GtkInvisible - selections don't work properly
+       with now NO_WINDOW GtkToggleButton. (Example really
+       should be using GtkClipboard.)
+
+       * gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
+       Fix  problems if sizeof(GdkAtom) != sizeof(Atom). (Unlikely)
+
+       * gdk/x11/gdkproperty-x11.c (gdk_property_get): Set 
+       actual_length when converting atoms as well.
+       (Gregory Merchan, #72074)
+
 2002-02-24  Havoc Pennington  <hp@pobox.com>
        
        * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to
index 0b7f35b4af68394138ef1939e4144ef06dfbcd5a..8ad5e26dae52fef94d1c3efdb002867a8157c6a2 100644 (file)
@@ -1,3 +1,17 @@
+Sun Feb 24 23:23:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * tests/testselection.c (main): Convert over to using
+       an GtkInvisible - selections don't work properly
+       with now NO_WINDOW GtkToggleButton. (Example really
+       should be using GtkClipboard.)
+
+       * gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
+       Fix  problems if sizeof(GdkAtom) != sizeof(Atom). (Unlikely)
+
+       * gdk/x11/gdkproperty-x11.c (gdk_property_get): Set 
+       actual_length when converting atoms as well.
+       (Gregory Merchan, #72074)
+
 2002-02-24  Havoc Pennington  <hp@pobox.com>
        
        * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to
index 0b7f35b4af68394138ef1939e4144ef06dfbcd5a..8ad5e26dae52fef94d1c3efdb002867a8157c6a2 100644 (file)
@@ -1,3 +1,17 @@
+Sun Feb 24 23:23:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * tests/testselection.c (main): Convert over to using
+       an GtkInvisible - selections don't work properly
+       with now NO_WINDOW GtkToggleButton. (Example really
+       should be using GtkClipboard.)
+
+       * gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
+       Fix  problems if sizeof(GdkAtom) != sizeof(Atom). (Unlikely)
+
+       * gdk/x11/gdkproperty-x11.c (gdk_property_get): Set 
+       actual_length when converting atoms as well.
+       (Gregory Merchan, #72074)
+
 2002-02-24  Havoc Pennington  <hp@pobox.com>
        
        * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to
index 0b7f35b4af68394138ef1939e4144ef06dfbcd5a..8ad5e26dae52fef94d1c3efdb002867a8157c6a2 100644 (file)
@@ -1,3 +1,17 @@
+Sun Feb 24 23:23:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * tests/testselection.c (main): Convert over to using
+       an GtkInvisible - selections don't work properly
+       with now NO_WINDOW GtkToggleButton. (Example really
+       should be using GtkClipboard.)
+
+       * gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
+       Fix  problems if sizeof(GdkAtom) != sizeof(Atom). (Unlikely)
+
+       * gdk/x11/gdkproperty-x11.c (gdk_property_get): Set 
+       actual_length when converting atoms as well.
+       (Gregory Merchan, #72074)
+
 2002-02-24  Havoc Pennington  <hp@pobox.com>
        
        * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to
index 74abf87adbdb407de726b7ca040d699ee5f852c6..b5295d506815da8b4002cf4da94822a8d6b090a5 100644 (file)
@@ -397,6 +397,9 @@ gdk_property_get (GdkWindow   *window,
 
          for (i = 0; i < ret_nitems; i++)
            ret_atoms[i] = gdk_x11_xatom_to_atom (xatoms[i]);
+
+         if (actual_length)
+           *actual_length = ret_nitems * sizeof (GdkAtom);
        }
       else
        {
index 2a4919dea9572470d22f51a182a5a1a0696f978f..3ddd69e036b7d5400775b4ae3d79db09ebd7b467 100644 (file)
@@ -244,21 +244,24 @@ gdk_selection_property_get (GdkWindow  *requestor,
 
   if (prop_type != None)
     {
-      *data = g_new (guchar, length);
-
       if (prop_type == XA_ATOM || prop_type == gdk_x11_get_xatom_by_name ("ATOM_PAIR"))
        {
          Atom* atoms = (Atom*) t;
-         GdkAtom* atoms_dest = (GdkAtom*) *data;
+         GdkAtom* atoms_dest;
          gint num_atom, i;
+
+         num_atom = (length - 1) / sizeof (Atom);
+         length = sizeof (GdkAtom) * num_atom + 1;
+         *data = g_malloc (length);
+         (*data)[length - 1] = '\0';
+         atoms_dest = (GdkAtom *)(*data);
          
-         num_atom = (length - 1) / sizeof (GdkAtom);
          for (i=0; i < num_atom; i++)
            atoms_dest[i] = gdk_x11_xatom_to_atom (atoms[i]);
        }
       else
        {
-         memcpy (*data, t, length);
+         *data = g_memdup (t, length);
        }
       
       if (t)
index 1731fe57c0711e639f2fa4d4c8e2afce5d1e6b1f..3f3d6830ccd8d87a2f2851279ef31a79e5d91ff6 100644 (file)
@@ -105,6 +105,7 @@ static int num_targets = sizeof(targets)/sizeof(Target);
 
 static int have_selection = FALSE;
 
+GtkWidget *selection_widget;
 GtkWidget *selection_text;
 GtkWidget *selection_button;
 GString *selection_string = NULL;
@@ -367,7 +368,7 @@ paste (GtkWidget *widget, GtkWidget *entry)
       return;
     }
 
-  gtk_selection_convert (selection_button, GDK_SELECTION_PRIMARY, atom, 
+  gtk_selection_convert (selection_widget, GDK_SELECTION_PRIMARY, atom, 
                         GDK_CURRENT_TIME);
 }
 
@@ -400,6 +401,8 @@ main (int argc, char *argv[])
 
   init_atoms();
 
+  selection_widget = gtk_invisible_new ();
+
   dialog = gtk_dialog_new ();
   gtk_widget_set_name (dialog, "Test Input");
   gtk_container_set_border_width (GTK_CONTAINER(dialog), 0);
@@ -425,15 +428,15 @@ main (int argc, char *argv[])
 
   gtk_signal_connect (GTK_OBJECT(selection_button), "toggled",
                      GTK_SIGNAL_FUNC (selection_toggled), NULL);
-  gtk_signal_connect (GTK_OBJECT(selection_button), "selection_clear_event",
+  gtk_signal_connect (GTK_OBJECT(selection_widget), "selection_clear_event",
                      GTK_SIGNAL_FUNC (selection_clear), NULL);
-  gtk_signal_connect (GTK_OBJECT(selection_button), "selection_received",
+  gtk_signal_connect (GTK_OBJECT(selection_widget), "selection_received",
                      GTK_SIGNAL_FUNC (selection_received), NULL);
 
-  gtk_selection_add_targets (selection_button, GDK_SELECTION_PRIMARY,
+  gtk_selection_add_targets (selection_widget, GDK_SELECTION_PRIMARY,
                             targetlist, ntargets);
 
-  gtk_signal_connect (GTK_OBJECT(selection_button), "selection_get",
+  gtk_signal_connect (GTK_OBJECT(selection_widget), "selection_get",
                      GTK_SIGNAL_FUNC (selection_get), NULL);
 
   selection_text = gtk_text_new (NULL, NULL);